/**
 * This code is part of the Bumpslide Library by David Knape
 * http://bumpslide.com/
 * 
 * Copyright (c) 2006, 2007, 2008 by Bumpslide, Inc.
 * 
 * Released under the open-source MIT license.
 * http://www.opensource.org/licenses/mit-license.php
 * see LICENSE.txt for full license terms
 */
 package {
	import com.bumpslide.ui.Applet;
	import com.bumpslide.ui.Image;
	import com.bumpslide.ui.Panel;		

	/**
	 * Panel Test with Resizable Content
	 * 
	 * If the panel content is resizable (IResizable), it calls setSize on it instead of 
	 * just cropping it.  Here, we load in a bumpslide image component instead 
	 * of a bare loader, and we set it's scale mode to crop.  This will make it fill 
	 * the available space assigned to it by the panel. 
	 * 
	 * @mxmlc -sp+=../../classes -default-frame-rate=31
	 * @author David Knape
	 */
	public class Demo_02_PanelWithResizableContent extends Applet {

		private var panel:Panel;
		private var image:Image;

		override protected function addChildren():void {
			
			// create panel
			panel = new Panel();
			panel.move(10, 10);
			
			// create image
			image = new Image();
			image.scaleMode = Image.SCALE_CROP;
			image.load('http://farm4.static.flickr.com/3053/2572693685_c5a3718e05.jpg');
			
			// put image inside the panel
			panel.content = image;
			
			// show the panel
			addChild(panel);
		}

		// on resize, update panel size
		override protected function draw():void {
			panel.setSize(width - 20, height - 20);
		}
	}
}
